package org.glow.changgou.framework.exception;

import org.glow.changgou.entity.Result;
import org.glow.changgou.entity.StatusCode;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @Author Glow
 * @Date 2022-09-20 17:54:40
 * @Description 统一异常处理
 * @Version 1.0
 */
@ControllerAdvice
public class BaseExceptionHandler {


    /**
     * 简易异常处理
     * @param e
     * @return
     */
    @ExceptionHandler(value = Exception.class)
    @ResponseBody
    public Result error(Exception e)
    {
        e.printStackTrace();
        return new Result(false, StatusCode.ERROR,e.getMessage());
    }
}
